package stack

import org.springframework.cloud.contract.spec.Contract

Contract.make {
    request {
        method("POST")
        url("/api/v3/stacks")
        headers {
            contentType(applicationJsonUtf8())
            header("id", 1)
        }
        body("""
            {
                "image":"java:alpine",
                "description":"javaceshi",
            }
        """)
        bodyMatchers {
            jsonPath('$.image', byRegex("[\\s\\S]+"))
            jsonPath('$.description', byRegex("[\\s\\S]+"))
        }
    }
    response {
        status(201)
        body("""
            {
                "uri":"/api/v3/stacks/1",
                "id":"1",
                "state":"SUCCESS"
            }
        """)
        bodyMatchers {
            jsonPath('$.uri', byRegex("[\\s\\S]+"))
            jsonPath('$.id', byRegex(number()))
            jsonPath('$.state', byRegex("[\\s\\S]+"))
        }
        headers {
            contentType(applicationJsonUtf8())
        }
    }
}
